package assignment1.eventplan.request;

import android.os.Handler;
import android.os.Looper;

import java.util.concurrent.Executor;

public class ResponseDelivery {

    final Executor poster;

    public ResponseDelivery(final Handler handler) {
        poster = new Executor() {
            @Override
            public void execute(Runnable command) {
                handler.post(command);
            }
        };
    }


    public void postResponse(final Request request, final Response response) {
        poster.execute(new Runnable() {
            @Override
            public void run() {
                request.onResponse(response);
            }
        });
    }
}
